<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>账户项目后台管理系统</title>
    <meta name="keywords" content="账户项目后台管理系统">
    <meta name="description" content="账户项目后台管理系统">
    <link rel="shortcut icon" href="/favicon.ico">

    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/font-awesome.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css" rel="stylesheet">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

    <style type="text/css">
        .help-block{text-align: left;}
    </style>

</head>
<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name"><img src="/img/logo.png" /></h1>
        </div>
        <h3>欢迎使用账户项目后台</h3>
        <form role="form" class="form-horizontal login-form" id="commentForm" >
            <div class="form-group ">
                <input id="username" name="username" class="form-control usernameshow" type="text" placeholder=" 登录帐号">
            </div>
            <div class="form-group">
                <input id="password" name="password" class="form-control passwordshow" type="password" placeholder=" 登录密码">
            </div>
            <button type="submit" class="btn btn-primary block full-width m-b" >登 录</button>
            <p class="text-muted text-center"> <a href="<?= yii\helpers\Url::to(['site/forget-pass'])?>">忘记密码了？</a>
        </form>

    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>

<script type="text/javascript">
    $(function() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#commentForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true,
                    minlength: 5
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的登录帐号"
                },
                password: {
                    required: icon + "请输入您的登录密码",
                    minlength: icon + "密码必须5个字符以上"
                }
            },
            submitHandler:function() {
                $.ajax({
                    type: 'post',
                    url: "login",
                    dataType: 'json',
                    async: false,
                    cache: false,
                    data: $(".login-form").serialize(),
                    success: function (msg) {
                        if (msg.code != 20000) {
                            alert(msg.message);
                        } else {
                            window.location.href = '<?= yii\helpers\Url::to(['/site/demo'])?>';
                        }
                    }
                });
            }
        });
    })
</script>
</body>
</html>


